<!--
 * @Author: 45654 2275061717@qq.com
 * @Date: 2022-10-12 14:12:13
 * @LastEditors: 45654 2275061717@qq.com
 * @LastEditTime: 2022-10-13 18:38:57
 * @FilePath: \实训三\小组餐饮平台项目\team-cooperation-project\src\pages\admin\log\List.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <!-- 表格区域 -->
    <template>
      <el-table
        :data="baseLogs"
        style="width: 100%"
        :header-cell-style="{ 'text-align': 'center' }"
        :cell-style="{ 'text-align': 'center' }"
      >
        <el-table-column prop="id" label="序号" width="60">
          <template slot-scope="scope">
            {{ scope.$index+1 }}
          </template>
        </el-table-column>
        <el-table-column prop="realname" label="访问人真实性名" />
        <el-table-column prop="method" label="访问方式" />
        <el-table-column prop="content" label="访问路径" />
        <el-table-column prop="logTime" label="访问时间">
          <template slot-scope="scope">
            <div>
              {{ scope.row.logTime | fmtDate }}
            </div>
          </template>
        </el-table-column>
      </el-table>
    </template>
    <!-- 表格区域结束 -->

    <!-- 分页组件 -->
    <el-pagination
      class="page"
      :current-page="params.page"
      :page-sizes="[2, 5, 10, 15, 20]"
      :page-size="params.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
    <!-- 分页组件结束 -->
  </div>
</template>

<script>
import { get } from '@/utils/request'
import fmtDate from '@/filters/index'
export default {
  data() {
    return {
      // 所有日志变量
      baseLogs: [],
      // 页码
      params: {
        page: 1,
        pageSize: 10
      },
      // 所有数据总条数
      total: 0
    }
  },
  computed: {},
  created() {
    this.getAllbaseLog()
  },
  mounted() {},
  methods: {
    // 页码条数发生改变事件  默认参数pageSize
    handleSizeChange(pageSize) {
      this.params.pageSize = pageSize
      this.params.page = 1
      this.getAllbaseLog()
    },
    // 当前页码发生触发的方法 默认参数是page
    handleCurrentChange(page) {
      this.params.page = page
      this.getAllbaseLog()
    },
    // 获取所有日志
    async getAllbaseLog() {
      const res = await get('/baseLog/pageQuery', this.params)
      this.baseLogs = res.data.list
      this.total = res.data.total
      console.log(res.data.list)
    }
  }
}
</script>
<style lang="scss">
.page{
  float: right;
}

</style>
